package ru.ifmo.kis;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import ru.ifmo.kis.domain.Material;

import java.util.logging.Logger;

/**
 * @author ivan
 */
public class Main {
	// in fact j2se embeded logger is worst so use other one  
	private static final Logger log = Logger.getLogger(HibernateUtil.class.toString());

	public static void main(String[] args) {
		SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
		Session session = sessionFactory.openSession();
		final Transaction tx = session.beginTransaction();

		Material material = new Material();
		material.setName("Haaaha");
		material.setVolume(100.);
		material.setCount(10);
		log.info("Id=" + session.save(material));
		session.flush();

//		Material m = (Material) session.load(Material.class, 1);
		tx.commit();
		session.close();
	}
}

